<?php

namespace app\modules\film\service;

use Yii;
use app\common\behaviors\ApiCommonBehavior;
use app\common\base\ApiService;
use app\modules\film\models\RecordTicketBuy;
use DateTime;
use PhpOffice\PhpSpreadsheet\Shared\Date;

class RecordTicketBuyService extends ApiService
{
    function __construct()
    {
        parent::init();
        $this->model = new RecordTicketBuy();
    }

    /**
     * 通过条件筛选;
     */
    public function getByCondition($condition){
        $init = [
            'status' => 1,
        ];
        $condition = array_merge($condition, $init);

        $infos = $this->lists([
            'condition' => $condition,
            'with' => ['filmBasic'],
        ]);

        foreach($infos as &$info){
            $filmBasic = $info['filmBasic'][0];
            $filmName = $filmBasic['filmName'][0]['film_name'];
            unset($info['filmBasic']);
            unset($filmBasic['filmName']);

            $info['film_id'] = $filmBasic['film_id'];
            $info['film_name'] = $filmName;
            $info['video_hall'] = $filmBasic['video_hall'];
            $info['show_times'] = $filmBasic['show_times'];
            $info['open_time'] = $filmBasic['open_time'];
        }


        return $infos;
    }

}

